package pro.softzhang.algo.lc2000;

import pro.softzhang.algo.common.ListNode;
import pro.softzhang.algo.flag.knowledge.KDoublePointer;
import pro.softzhang.algo.flag.x.XOptimal;

/**
 *
 */
public class LC2095_DeleteTheMiddleNodeOfALinkedList {
    public static void main(String[] args) {

    }

    @KDoublePointer
    @XOptimal
    static
    class Solution {
        public ListNode deleteMiddle(ListNode head) {
            ListNode slow = head, fast = head.next;
            if (fast == null) {
                return null;
            }
            while (fast.next != null && fast.next.next != null) {
                slow = slow.next;
                fast = fast.next.next;
            }
            slow.next = slow.next.next;
            return head;
        }
    }
}
